package com.ruoyi.server.api.venueManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.server.api.venueManagement.domain.VenueManagement;
import com.ruoyi.server.api.venueManagement.service.IVenueManagementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 场馆管理Controller
 *
 * @author hjh
 * @date 2024-06-12
 */
@RestController
@RequestMapping("/venueManagement/management")
public class VenueManagementController extends BaseController {
    @Autowired
    private IVenueManagementService venueManagementService;

    /**
     * 查询场馆管理列表
     */
    @PreAuthorize("@ss.hasPermi('venueManagement:management:list')")
    @GetMapping("/list")
    public TableDataInfo list(VenueManagement venueManagement) {
        startPage();
        List<VenueManagement> list = venueManagementService.selectVenueManagementList(venueManagement);
        return getDataTable(list);
    }

    /**
     * 导出场馆管理列表
     */
    @PreAuthorize("@ss.hasPermi('venueManagement:management:export')")
    @Log(title = "场馆管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VenueManagement venueManagement) {
        List<VenueManagement> list = venueManagementService.selectVenueManagementList(venueManagement);
        ExcelUtil<VenueManagement> util = new ExcelUtil<VenueManagement>(VenueManagement.class);
        util.exportExcel(response, list, "场馆管理数据");
    }

    /**
     * 获取场馆管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('venueManagement:management:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(venueManagementService.selectVenueManagementById(id));
    }

    /**
     * 新增场馆管理
     */
    @PreAuthorize("@ss.hasPermi('venueManagement:management:add')")
    @Log(title = "场馆管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VenueManagement venueManagement) {
        return toAjax(venueManagementService.insertVenueManagement(venueManagement));
    }

    /**
     * 修改场馆管理
     */
    @PreAuthorize("@ss.hasPermi('venueManagement:management:edit')")
    @Log(title = "场馆管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VenueManagement venueManagement) {
        return toAjax(venueManagementService.updateVenueManagement(venueManagement));
    }

    /**
     * 删除场馆管理
     */
    @PreAuthorize("@ss.hasPermi('venueManagement:management:remove')")
    @Log(title = "场馆管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(venueManagementService.deleteVenueManagementByIds(ids));
    }

    /**
     * @Author hjh
     * @Description 获取场馆最大人数
     * @Date 2024/6/12 20:22
     * @Return com.ruoyi.common.core.domain.AjaxResult
     */
    @Log(title = "获取场馆最大人数", businessType = BusinessType.OTHER)
    @GetMapping("getVenueMaxNumber")
    public AjaxResult getVenueMaxNumber() {
        return AjaxResult.success(venueManagementService.getVenueMaxNumber());
    }
}
